package conversion

import (
	"strconv"
	"strings"
	"time"
)

func  YamlTimeToInt(input map[string]interface{}) (err error)  {
	// 在这里对input进行处理即可
	// 您可能需要定义一个递归的函数，来处理嵌套的map结构
	for _,v := range input{
		switch vt := v.(type) {
		case map[string]interface{}:
			for k2,v1 := range vt{
				if _,ok := v1.(string); ok {
					if strings.Contains(v1.(string),"s") {
						strs := strings.Split(v1.(string),"s")
						if _,err :=strconv.ParseFloat(strs[0],64); err == nil {
							n,_ := strconv.Atoi(strs[0])
							vt[k2] = time.Duration(n) * time.Second
						}
					}
					if strings.Contains(v1.(string),"ms") {
						strs := strings.Split(v1.(string),"ms")
						if _,err :=strconv.ParseFloat(strs[0],64); err == nil {
							n,_ := strconv.Atoi(strs[0])
							vt[k2] = time.Duration(n) * time.Millisecond
						}

					}
				}
			}
		}
	}
	return
}